/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jbase.demo;

/**
 *
 * @author Administrator
 * 
 *  override 了对象的equals方法
 */
public class Student {
    private String name;
    private int age;

    public Student() {
    }
   
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Student other = (Student) obj;
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
            return false;
        }
//        return true;
        return this.name.equals(other.name) && this.age == other.age;
    }
    
}
